﻿#region Using directives

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

#endregion

namespace Weazel.Toad.Application.Forms
{
  partial class GotoLineForm : Form
  {
    private int lineNumber;
    public int LineNumber
    {
      get { return lineNumber; }
    }

    public GotoLineForm()
    {
      InitializeComponent();
    }

    private void cancelButton_Click(object sender, EventArgs e)
    {
      DialogResult = DialogResult.Cancel;
      Close();
    }

    private void okButton_Click(object sender, EventArgs e)
    {
      if (validateLineNumber())
      {
        DialogResult = DialogResult.OK;
        Close();
      }
    }

    private bool validateLineNumber()
    {
      bool resultOk = true;
      try
      {
        lineNumber = int.Parse(lineNumberTextBox.Text);

        if (lineNumber < 1)
          resultOk = false;
      }
      catch
      {
        resultOk = false;
      }

      if(!resultOk) 
        MessageBox.Show("Invalid line number");

      return resultOk;
    }
  }
}